//app.js
var util = require('./utils/utils.js');
var api = require('./api.js');
App({
    onLaunch: function () {
       
    },

    // 登录超时
    expirate_load:function(){
      wx.showLoading({
        title: '登录超时，请重新登录',
      });
      
      setTimeout(function(){
        wx.setStorageSync("user_info", "");
        wx.redirectTo({
          url: '/pages/login/login',
        })
        wx.hideLoading();
      },2000)

    },
    
    request: function (object) {
        var access_token = wx.getStorageSync("access_token");
        if (access_token) {
            if (!object.data)
                object.data = {};
            object.data.access_token = access_token;
        }
        wx.request({
            url: object.url,
            header: object.header || {
                'content-type': 'application/x-www-form-urlencoded'
            },
            data: object.data || {},
            method: object.method || "GET",
            dataType: object.dataType || "json",
            success: function (res) {
                if (res.data.code == -1) {
                    getApp().login();
                } else {
                    if (object.success)
                        object.success(res.data);
                }
            },
            fail: function (res) {
                if (object.fail)
                    object.fail(res);
            },
            complete: function (res) {
                if (object.complete)
                    object.complete(res);
            }
        });
    },
    
  globalData: {
    // host: "https://helton.atakeoff.cn",
    host: "https://hilton.tkkks.com",
    // host: "http://www.helton.com",
    allAddress:null,
    Wxuser: null,
    subDomain: "mall",
    token:null,
    tk_id:1,
  },
});